package usually;
//75. 颜色分类
public class Num75_sortColors {
    public void sortColors(int[] nums) {

        int p = 0;
        for (int i = 0; i < nums.length; i++) {
            if (nums[i]==0){
                swap(nums,p,i);
                p++;
            }
        }
        for (int i = p; i < nums.length; i++) {
            if (nums[i] == 1){
                swap(nums,i,p);
                p++;
            }
        }

    }
    public static void swap(int []arr,int i,int j){
        int temp = arr[i];
        arr[i] = arr[j];
        arr[j] = temp;

    }





}
